package com.mantru.iotpot.setting;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.RecyclerView;

import com.mantru.iotpot.ApplicationClass;
import com.mantru.iotpot.R;

import java.nio.FloatBuffer;

public class AboutMeActivity extends AppCompatActivity implements View.OnClickListener {
    private ApplicationClass ac;
    private LinearLayout back;
    private TextView name;
    private TextView type;
    private TextView model;
    private TextView id;
    private TextView hardware_version;
    private TextView app_version;
    private TextView system_version;
    private RelativeLayout qrcode;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_me);
        ac = (ApplicationClass) getApplication();// 初始化 ApplicationClass
        initialization();
    }

    //初始化控件的方法
    private void initialization(){
        back = findViewById(R.id.about_me_back);
        name = findViewById(R.id.about_me_name);
        type = findViewById(R.id.about_me_type);
        model = findViewById(R.id.about_me_model);
        id = findViewById(R.id.about_me_id);
        hardware_version = findViewById(R.id.about_me_hardware_version);
        app_version = findViewById(R.id.about_me_app_version);
        system_version = findViewById(R.id.about_me_system_version);
        qrcode = findViewById(R.id.about_me_qrcode);
        back.setOnClickListener(this);
        qrcode.setOnClickListener(this);

        name.setText(ac.activity_device_name);//获取本机名称
        Log.d("AboutMeActivity","本机名称: " + ac.activity_device_name);
        id.setText(ac.activity_device_id);//获取设备ID
        Log.d("AboutMeActivity","设备ID: " + ac.activity_device_id);
        app_version.setText(ac.APP_Version);
        Log.d("AboutMeActivity","APP版本号: " + ac.APP_Version);
        system_version.setText(ac.activity_software_version);
        Log.d("AboutMeActivity","系统版本号: " + ac.activity_software_version);
        hardware_version.setText(ac.activity_hardware_version);
        Log.d("AboutMeActivity","硬件版本号: " + ac.activity_hardware_version);
        type.setText(ac.activity_device_type);
        Log.d("AboutMeActivity","机器类型: " + ac.activity_device_type);
        model.setText(ac.activity_device_spec);
        Log.d("AboutMeActivity","型号: " + ac.activity_device_spec);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.about_me_back){
            finish();
        } else if (v.getId() == R.id.about_me_qrcode) {
            Intent intent = new Intent(this, QRCodeActivity.class);
            intent.putExtra("app_id",ac.activity_device_id);
            startActivity(intent);
        }
    }
}